package com.gui.hospital.controller;

import com.gui.entity.R;
import com.gui.hospital.model.Doctor;
import com.gui.hospital.service.DoctorService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
import java.util.List;

/**
 * @author 言叶
 * Date：2025/9/4
 */
@RestController //相当于@Controller + @ResponseBody
@RequestMapping("/doctor")
@AllArgsConstructor // 构造器自动注入
@CrossOrigin // 允许跨域
public class DoctorController {
    private final DoctorService doctorService;

    /*
     * 根据科室id和时间查询对应的医生的排班信息
     */
    @GetMapping("/findByDeptIdAndTime")
    public R<List<Doctor>> findByDepartmentIdAndTime(Integer deptId, String time) {
        List<Doctor> list = doctorService.findByDeptIdAndTime(deptId, time);
        return new R<>(list);
    }
    /*
     * 根据id查询
     */
    @GetMapping("/getById/{id}")
    public Doctor getById(@PathVariable("id") Integer id) {
        return doctorService.getById(id);
    }
}
